package com.lt.lumentracks.controller;

import com.lt.lumentracks.entity.po.Topic;
import com.lt.lumentracks.entity.vo.common.PageVO;
import com.lt.lumentracks.entity.vo.common.Result;
import com.lt.lumentracks.service.ITopicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 热门话题表 前端控制器
 * </p>
 *
 * @author swl
 * @since 2025-07-23
 */
@RestController
@RequestMapping("/topic")
public class TopicController {

    @Autowired
    private ITopicService iTopicService;

    // 分页获取所有话题
    @GetMapping("getAllTopicByPage")
    public Result<PageVO<Topic>> getAllTopicByPage(@RequestParam(defaultValue = "1") long current,
                                                 @RequestParam(defaultValue = "10") long size) {
        PageVO<Topic> res = iTopicService.getAllTopicByPage(current, size);
        return Result.success(res);
    }


    // 根据传入的话题id进行查询
    @PostMapping("getTopicByIds")
    public Result<List<Topic>> getTopicByIds(@RequestBody List<Integer> ids) {
        List<Topic> res = iTopicService.getTopicByIds(ids);
        return Result.success(res);
    }


}
